package poj;

import java.io.BufferedInputStream;
import java.util.Arrays;
import java.util.Scanner;

public class AKnightJourney {

	//按照字典序
	private static final int[][] dir = { { -2, -1 }, { -2, 1 }, { -1, -2 }, { -1, 2}, { 1, -2 },
			{ 1, 2 }, { 2, -1 }, { 2, 1 } };
	private static final int MAX = 30;
	
	int rows, columns;
	boolean canArrive = false;
	
	private int ways[][] = new int[MAX][2];	//记录路径
	private boolean[][] visited = new boolean[MAX][MAX];
	
	public static void main(String[] args) {
		AKnightJourney object = new AKnightJourney();
		object.getRes();
	}

	public void getRes(){
		Scanner scanner = new Scanner(new BufferedInputStream(System.in));
		int testCase  = scanner.nextInt();
		for(int t = 1; t <= testCase; t++){
			columns = scanner.nextInt();
			rows = scanner.nextInt();
			for(int i = 0; i < rows; i++){
				Arrays.fill(visited[i], false);
			}
			for(int i = 0; i < ways.length; i++){
				ways[i][0] = 0;
				ways[i][1] = 0;
			}
			canArrive = false;
			visited[1][1] = true;
			dfs(1, 1, 1);
			System.out.println("Scenario #" + t + ":");
			if(canArrive){
				int num = rows * columns;
				for(int i = 1; i <= num; i++){
					System.out.printf("%c%d", ways[i][0] + 'A' - 1, ways[i][1]);
				}
			}else{
				System.out.print("impossible");
			}
			System.out.println();
			if(t != testCase){
				System.out.println();
			}
		}
		scanner.close();
	}
	
	//Runtime 313MS
	public void dfs(int x, int y, int num){
		ways[num][0] = x;
		ways[num][1] = y;
		if(num == rows * columns){
			canArrive = true;
			return;
		}
		for(int i = 0; i < dir.length; i++){
			int curX = x + dir[i][0];
			int curY = y + dir[i][1];
			if(curX < 1 || curX > rows || curY < 1 || curY > columns || visited[curX][curY] || canArrive){
				continue;
			}
			visited[curX][curY] = true;
			dfs(curX, curY, num + 1);
//			if(canArrive){
//				return;
//			}
			visited[curX][curY] = false;
		}
	}
}
